package com.zjitc.redis;

import com.zjitc.dao.UserDao;
import com.zjitc.model.User;
import java.awt.event.ItemEvent;
import java.util.HashMap;
import java.util.List;
import org.apache.ibatis.scripting.xmltags.ForEachSqlNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/12 16:19
 * @description:
 */
@Component
public class Rediss {
  @Autowired
  private static Jedis jedis;

  @Autowired
  public Rediss(UserDao userDao){
    jedis = new Jedis();
    List<User> list = userDao.findAllUser();
    list.forEach((item)->{
      HashMap<String,String> map = new HashMap<>();
      map.put("a", String.valueOf(item));
      jedis.hmset(String.valueOf(item.getId()),map);
    });
  }

}
